﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace TheBox
{
    class Fire
    {
        public static int Height = 2;
        public static int Width = 2;
        public Vector2 Speed = new Vector2(0,0);
        public Vector2 Pos;
        public Box BaseBox;
        public Texture2D Texture;
        public Rectangle Rect;
        public static int FireSpeed = -150;
        public Player MyPlayer;

        public Fire(Box baseBox, Texture2D texture, Player player)
        {
            BaseBox = baseBox;
            Texture = texture;
            Pos = player.Pos;
            Matrix rotationMatrix = Matrix.CreateRotationZ(-1 * BaseBox.Rotation + player.Rotation);
            Speed += Vector2.Transform(new Vector2(0,1), rotationMatrix) * FireSpeed;
            MyPlayer = player;
        }

        public void update(GameTime gameTime)
        {
            Matrix rotationMatrix = Matrix.CreateRotationZ(-1 * BaseBox.Rotation);
            Pos += Speed * (float)gameTime.ElapsedGameTime.TotalSeconds;

            rotationMatrix = Matrix.CreateRotationZ(BaseBox.Rotation);
            Vector2 newPos = Vector2.Transform(Pos - Box.Origin, rotationMatrix) + BaseBox.Position;
            Rect = new Rectangle((int)newPos.X - Width / 2, (int)newPos.Y - Height / 2, Width, Height);

        }

    }
}
